Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import-io/improvement #171

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

import-io/improvement #171

wants to merge 3 commits into from

Conversation

du-phan
Copy link
Contributor

@du-phan du-phan commented Dec 18, 2019

DO NOT MERGE

  • Add code-env
  • Add support for python 3

Copy link
Contributor

@JoachimZ JoachimZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a plugin that is supposed to work now, please check hello world works in py2 and 3 (and write the you already tested that in the PR desc)

input_schema_names = frozenset([e['name'] for e in input.read_schema()])
output_schema = input.read_schema()
print(')))))))))')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug?

from dataiku.customrecipe import *
import logging

logger = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't basic config necessary?
I'd rather not use name and not even use logger =
just use logging.basicConfig with a decent format (for example I probably did something not horrible for example in azure cognitive services plugins) and then just use logging.info

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Joachim, we should share config (nothing fancy, just simple stuff) across plugins)

@@ -13,24 +18,23 @@ def __init__(self, config):
elif self.config['api_url'].startswith('https://extraction.import.io/'):
self.api_version = 'extraction'
else:
raise Exception(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe more specifically type the Exception, not necessarily custom but just a more descriptive exception class

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we should probably log the exception proper (might be having a moment - does raise do that natively?)

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved with comments

raise Exception(
'It looks like this URL is not an API URL. URLs to call the API (and get a json response) start with "https://api.import.io" .')
print '[import.io connector] calling API...'
raise Exception('It looks like this URL is not an API URL. URLs to call the API (and get a json response) start with "https://api.import.io" .')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like from the above if/else the url can also start with another prefix? Might be confusing to not log that

@@ -13,24 +18,23 @@ def __init__(self, config):
elif self.config['api_url'].startswith('https://extraction.import.io/'):
self.api_version = 'extraction'
else:
raise Exception(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also we should probably log the exception proper (might be having a moment - does raise do that natively?)

raise
logger.error(e)
logger.error('response was:{}'.format(response.text))
raise ValueError

def get_read_schema(self):
if self.api_version == 'api':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: couldn't api-version just be a None like value?

else:
return None
return None

def generate_rows(self, dataset_schema=None, dataset_partitioning=None, partition_id=None, records_limit = -1):
if self.api_version == 'api':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we testing this in every function? also why would api version be api

from dataiku.customrecipe import *
import logging

logger = logging.getLogger(__name__)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Joachim, we should share config (nothing fancy, just simple stuff) across plugins)

logger.error('request to import.io failed')
logger.error(e)
logger.error('response was: {}'.format(response))
raise ValueError
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't we masking exceptions? Why not just throw the actual exception? (There's sometimes reason to do this but I don't know if that is the case here as a number of things could be going wrong and it might help user to know)

input_schema_names = frozenset([e['name'] for e in input.read_schema()])
output_schema = input.read_schema()
print(')))))))))')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 with Joachim, idk what is going on here

@tdesfont tdesfont changed the title Import io/improvement import-io/improvement Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants